/**
 * Created by wash on 16/8/2.
 */


export function DateFormat (input) {

    return dateDiff(input);

    function dateDiff(hisTime,nowTime){
        if(!arguments.length) return '';
        var arg = arguments,
            now =arg[1]?arg[1]:new Date().getTime(),
            diffValue = now - arg[0],
            result='',

            minute = 1000 * 60,
            hour = minute * 60,
            day = hour * 24,
            halfamonth = day * 15,
            month = day * 30,
            year = month * 12,

            _year = diffValue/year,
            _month =diffValue/month,
            _week =diffValue/(7*day),
            _day =diffValue/day,
            _hour =diffValue/hour,
            _min =diffValue/minute;

        if(_year>=1) result=parseInt(_year) + "年前";
        else if(_month>=1) result=parseInt(_month) + "个月前";
        else if(_week>=1) result=parseInt(_week) + "周前";
        else if(_day>=1) result=parseInt(_day) +"天前";
        else if(_hour>=1) result=parseInt(_hour) +"个小时前";
        else if(_min>=1) result=parseInt(_min) +"分钟前";
        else result="刚刚";
        return result;
    }
}


export function Currency (val) {
    return '¥ '+val.toFixed(2);
}

/*const formatTimeStamp = function (stamp) {
    let date = new Date(1398250549490);
    let Y = date.getFullYear() + '-';
    let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
    let D = date.getDate() + ' ';
    let h = date.getHours() + ':';
    let m = date.getMinutes() + ':';
    let s = date.getSeconds();
    return Y+M+D+h+m+s;
}

exports.formatTimeStamp = formatTimeStamp;*/


